package com.bilibili.task;

import cn.hutool.cron.CronUtil;
import cn.hutool.cron.task.Task;
import com.bilibili.service.PicCollectionService;
import com.bilibili.service.VideoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

import static com.bilibili.constant.BusinessConstant.CRON_SYNC_REDIS_CLICK_COUNT_TO_MYSQL;


@Component
public class RedisClickCountToMySql {
    @Autowired
    private VideoService videoService;
    @Autowired
    private PicCollectionService picCollectionService;

    @PostConstruct
    public void execute() {
        CronUtil.schedule(CRON_SYNC_REDIS_CLICK_COUNT_TO_MYSQL, (Task) () -> videoService.syncRedisCompletequestionToMySql());
        // 支持秒级别定时任务
        CronUtil.setMatchSecond(true);
    }
}
